package com.wz;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;

public class MaoPaoSore {
	@Test
	public void a() {
		ArrayList<Integer> arr = new ArrayList();
		arr.add(6);
		arr.add(5);
		arr.add(3);
		arr.add(4);
		arr.add(2);
		Integer[] arrs = arr.toArray(new Integer[arr.size()]);
		System.out.println(arrs.length);
	}

	@Test
	public void b() {
		List<Integer> list = new ArrayList<>();
		list.add(9);
		list.add(5);
		list.add(3);
		list.add(2);
		list.add(7);
		list.add(6);
		int[] res = new int[list.size()];
		int n = 0;
		for (Integer num : list) {
			res[n] = num;
			n++;
		}
		System.out.println(res.length);
		System.out.println("排序前");
		for (int j = 0; j < res.length; j++) {
			System.out.print(res[j] + "  ");
		}
		System.out.println();

	/*	for (int o = 0, j = res.length - 1; o < j; o++, j--) {
			int temp = res[o];
			res[o] = res[j];
			res[j] = temp;
		}*/
		/**
		 * 冒泡排序
		 */
		for (int i = 0; i < res.length - 1; i++) {
			for (int j = 0; j < res.length - 1 - i; j++) {
				if (res[j] < res[j + 1]) {
					int temp = res[j];
					res[j] = res[j + 1];
					res[j + 1] = temp;
				}
			}
		}
		System.out.println("排序后---------------");
		for (int p = 0; p < res.length; p++) {
			System.out.print(res[p] + " , ");
		}
		System.out.println();
		System.out.println("反转---------------");
		for (int o = res.length - 1; o >= 0; o--) {
			System.out.print(res[o] + " , ");
		}
	}
}
